/*
 * Copyright (c) 2006-2010,2012-2016 Apple Inc. All Rights Reserved.
 */

#include <CoreFoundation/CoreFoundation.h>
#include <Security/SecCertificate.h>
#include <Security/SecCertificatePriv.h>
#include <Security/SecPolicy.h>
#include <Security/SecTrustPriv.h>
#include <utilities/array_size.h>
#include <stdlib.h>
#include <unistd.h>

#include "shared_regressions.h"

/* subject:/jurisdictionC=US/jurisdictionST=California/businessCategory=Private Organization/serialNumber=C0806592/C=US/postalCode=95014/ST=California/L=Cupertino/street=1 Infinite Loop/O=Apple Inc./OU=GNCS Traffic Management/CN=secure.store.apple.com */
/* issuer :/C=US/O=Symantec Corporation/OU=Symantec Trust Network/CN=Symantec Class 3 EV SSL CA - G3 */

// #### NOTE: valid from 16 Apr 2015 to 17 April 2017 ###
static unsigned char _c0[]={
    0x30,0x82,0x07,0x81,0x30,0x82,0x06,0x69,0xA0,0x03,0x02,0x01,0x02,0x02,0x10,0x5F,
    0x7C,0x39,0x94,0x36,0x3A,0x86,0x43,0xAA,0x98,0xD7,0xF2,0xDF,0x6C,0xDB,0x48,0x30,
    0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x30,0x77,
    0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x1D,0x30,
    0x1B,0x06,0x03,0x55,0x04,0x0A,0x13,0x14,0x53,0x79,0x6D,0x61,0x6E,0x74,0x65,0x63,
    0x20,0x43,0x6F,0x72,0x70,0x6F,0x72,0x61,0x74,0x69,0x6F,0x6E,0x31,0x1F,0x30,0x1D,
    0x06,0x03,0x55,0x04,0x0B,0x13,0x16,0x53,0x79,0x6D,0x61,0x6E,0x74,0x65,0x63,0x20,
    0x54,0x72,0x75,0x73,0x74,0x20,0x4E,0x65,0x74,0x77,0x6F,0x72,0x6B,0x31,0x28,0x30,
    0x26,0x06,0x03,0x55,0x04,0x03,0x13,0x1F,0x53,0x79,0x6D,0x61,0x6E,0x74,0x65,0x63,
    0x20,0x43,0x6C,0x61,0x73,0x73,0x20,0x33,0x20,0x45,0x56,0x20,0x53,0x53,0x4C,0x20,
    0x43,0x41,0x20,0x2D,0x20,0x47,0x33,0x30,0x1E,0x17,0x0D,0x31,0x35,0x30,0x34,0x31,
    0x37,0x30,0x30,0x30,0x30,0x30,0x30,0x5A,0x17,0x0D,0x31,0x37,0x30,0x34,0x31,0x37,
    0x32,0x33,0x35,0x39,0x35,0x39,0x5A,0x30,0x82,0x01,0x1C,0x31,0x13,0x30,0x11,0x06,
    0x0B,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x3C,0x02,0x01,0x03,0x13,0x02,0x55,0x53,
    0x31,0x1B,0x30,0x19,0x06,0x0B,0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x3C,0x02,0x01,
    0x02,0x0C,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x1D,0x30,
    0x1B,0x06,0x03,0x55,0x04,0x0F,0x13,0x14,0x50,0x72,0x69,0x76,0x61,0x74,0x65,0x20,
    0x4F,0x72,0x67,0x61,0x6E,0x69,0x7A,0x61,0x74,0x69,0x6F,0x6E,0x31,0x11,0x30,0x0F,
    0x06,0x03,0x55,0x04,0x05,0x13,0x08,0x43,0x30,0x38,0x30,0x36,0x35,0x39,0x32,0x31,
    0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x0E,0x30,0x0C,
    0x06,0x03,0x55,0x04,0x11,0x0C,0x05,0x39,0x35,0x30,0x31,0x34,0x31,0x13,0x30,0x11,
    0x06,0x03,0x55,0x04,0x08,0x0C,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,
    0x61,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x07,0x0C,0x09,0x43,0x75,0x70,0x65,
    0x72,0x74,0x69,0x6E,0x6F,0x31,0x18,0x30,0x16,0x06,0x03,0x55,0x04,0x09,0x0C,0x0F,
    0x31,0x20,0x49,0x6E,0x66,0x69,0x6E,0x69,0x74,0x65,0x20,0x4C,0x6F,0x6F,0x70,0x31,
    0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x0A,0x0C,0x0A,0x41,0x70,0x70,0x6C,0x65,0x20,
    0x49,0x6E,0x63,0x2E,0x31,0x20,0x30,0x1E,0x06,0x03,0x55,0x04,0x0B,0x0C,0x17,0x47,
    0x4E,0x43,0x53,0x20,0x54,0x72,0x61,0x66,0x66,0x69,0x63,0x20,0x4D,0x61,0x6E,0x61,
    0x67,0x65,0x6D,0x65,0x6E,0x74,0x31,0x1F,0x30,0x1D,0x06,0x03,0x55,0x04,0x03,0x0C,
    0x16,0x73,0x65,0x63,0x75,0x72,0x65,0x2E,0x73,0x74,0x6F,0x72,0x65,0x2E,0x61,0x70,
    0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,0x09,0x2A,
    0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,0x00,0x30,
    0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0x8A,0xF0,0x79,0x88,0xDE,0x0A,0x7B,0x1A,
    0x8C,0xAE,0xE8,0xB5,0xB8,0x5E,0x77,0xFF,0x5D,0x54,0x30,0x8C,0x68,0xDA,0xDC,0x85,
    0xBC,0x2B,0x55,0x74,0x99,0x5E,0x3A,0x02,0x1B,0xE5,0xE4,0xE1,0x22,0x21,0xF0,0x43,
    0x7D,0x92,0x6B,0xAB,0xC8,0xF1,0x11,0x27,0x9C,0x49,0x24,0x98,0x8A,0xB4,0x39,0xD6,
    0x5A,0x47,0x29,0x21,0x5D,0xFB,0x90,0x0B,0x3C,0xE1,0x4C,0xEF,0x55,0x2F,0xC4,0xD0,
    0x1F,0x14,0xFB,0x80,0x63,0xCB,0xAA,0x5C,0x59,0xAD,0x03,0x48,0xB5,0x2B,0xE4,0xD5,
    0x89,0xE9,0x6B,0xCA,0x7E,0x2A,0x26,0x80,0x90,0xC3,0x57,0xEB,0xA7,0xF9,0x9A,0x13,
    0x37,0x6F,0xA7,0x7D,0x28,0x8D,0x30,0xCB,0x09,0x6B,0xD7,0xBC,0x94,0x0D,0xDD,0x35,
    0x86,0xD6,0xEA,0x0B,0x4F,0x97,0xCF,0x4E,0x13,0x49,0x3B,0x3C,0xC8,0xA1,0x54,0x3F,
    0x8F,0x51,0xD5,0x11,0x77,0xEB,0xB6,0x40,0x94,0xB3,0x96,0xDE,0x76,0x72,0x99,0x33,
    0xA4,0x63,0xD6,0xE8,0x9C,0xF3,0xAA,0xEB,0xB9,0x37,0xB2,0xED,0x3F,0x46,0x24,0x19,
    0x7D,0x2B,0xF7,0x73,0x47,0xC9,0x9A,0xC6,0x67,0x26,0x53,0x6F,0xE6,0x2A,0xE0,0x38,
    0x1F,0x64,0x7E,0x9F,0x27,0x77,0x55,0xA2,0x0C,0x94,0xE2,0x8A,0x8A,0x57,0xEA,0xF4,
    0xE8,0xE4,0x6E,0x68,0x78,0x8F,0x6F,0x26,0x5B,0x29,0xFB,0xD4,0xA5,0xC5,0x8B,0x9F,
    0xE6,0x02,0xF1,0x31,0x37,0x56,0xFE,0xB6,0xD4,0x3E,0xCC,0xE7,0x28,0x07,0x89,0xC3,
    0xD8,0x51,0x83,0x9B,0x5A,0x2F,0x41,0x54,0x9D,0xDF,0x48,0x6A,0x8F,0x1D,0xC1,0x4F,
    0x6B,0x4A,0x57,0x2C,0x09,0xF4,0x80,0x73,0x02,0x03,0x01,0x00,0x01,0xA3,0x82,0x03,
    0x60,0x30,0x82,0x03,0x5C,0x30,0x81,0x8C,0x06,0x03,0x55,0x1D,0x11,0x04,0x81,0x84,
    0x30,0x81,0x81,0x82,0x19,0x73,0x65,0x63,0x75,0x72,0x65,0x2E,0x6E,0x63,0x2D,0x73,
    0x74,0x6F,0x72,0x65,0x2E,0x61,0x70,0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,0x82,0x1A,
    0x73,0x65,0x63,0x75,0x72,0x65,0x2E,0x6E,0x77,0x6B,0x2D,0x73,0x74,0x6F,0x72,0x65,
    0x2E,0x61,0x70,0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,0x82,0x16,0x73,0x65,0x63,0x75,
    0x72,0x65,0x2E,0x73,0x74,0x6F,0x72,0x65,0x2E,0x61,0x70,0x70,0x6C,0x65,0x2E,0x63,
    0x6F,0x6D,0x82,0x17,0x73,0x65,0x63,0x75,0x72,0x65,0x31,0x2E,0x73,0x74,0x6F,0x72,
    0x65,0x2E,0x61,0x70,0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,0x82,0x17,0x73,0x65,0x63,
    0x75,0x72,0x65,0x32,0x2E,0x73,0x74,0x6F,0x72,0x65,0x2E,0x61,0x70,0x70,0x6C,0x65,
    0x2E,0x63,0x6F,0x6D,0x30,0x09,0x06,0x03,0x55,0x1D,0x13,0x04,0x02,0x30,0x00,0x30,
    0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x05,0xA0,0x30,
    0x1D,0x06,0x03,0x55,0x1D,0x25,0x04,0x16,0x30,0x14,0x06,0x08,0x2B,0x06,0x01,0x05,
    0x05,0x07,0x03,0x01,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x02,0x30,0x66,
    0x06,0x03,0x55,0x1D,0x20,0x04,0x5F,0x30,0x5D,0x30,0x5B,0x06,0x0B,0x60,0x86,0x48,
    0x01,0x86,0xF8,0x45,0x01,0x07,0x17,0x06,0x30,0x4C,0x30,0x23,0x06,0x08,0x2B,0x06,
    0x01,0x05,0x05,0x07,0x02,0x01,0x16,0x17,0x68,0x74,0x74,0x70,0x73,0x3A,0x2F,0x2F,
    0x64,0x2E,0x73,0x79,0x6D,0x63,0x62,0x2E,0x63,0x6F,0x6D,0x2F,0x63,0x70,0x73,0x30,
    0x25,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x02,0x02,0x30,0x19,0x1A,0x17,0x68,
    0x74,0x74,0x70,0x73,0x3A,0x2F,0x2F,0x64,0x2E,0x73,0x79,0x6D,0x63,0x62,0x2E,0x63,
    0x6F,0x6D,0x2F,0x72,0x70,0x61,0x30,0x1F,0x06,0x03,0x55,0x1D,0x23,0x04,0x18,0x30,
    0x16,0x80,0x14,0x01,0x59,0xAB,0xE7,0xDD,0x3A,0x0B,0x59,0xA6,0x64,0x63,0xD6,0xCF,
    0x20,0x07,0x57,0xD5,0x91,0xE7,0x6A,0x30,0x2B,0x06,0x03,0x55,0x1D,0x1F,0x04,0x24,
    0x30,0x22,0x30,0x20,0xA0,0x1E,0xA0,0x1C,0x86,0x1A,0x68,0x74,0x74,0x70,0x3A,0x2F,
    0x2F,0x73,0x72,0x2E,0x73,0x79,0x6D,0x63,0x62,0x2E,0x63,0x6F,0x6D,0x2F,0x73,0x72,
    0x2E,0x63,0x72,0x6C,0x30,0x57,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x01,
    0x04,0x4B,0x30,0x49,0x30,0x1F,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,
    0x86,0x13,0x68,0x74,0x74,0x70,0x3A,0x2F,0x2F,0x73,0x72,0x2E,0x73,0x79,0x6D,0x63,
    0x64,0x2E,0x63,0x6F,0x6D,0x30,0x26,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x30,
    0x02,0x86,0x1A,0x68,0x74,0x74,0x70,0x3A,0x2F,0x2F,0x73,0x72,0x2E,0x73,0x79,0x6D,
    0x63,0x62,0x2E,0x63,0x6F,0x6D,0x2F,0x73,0x72,0x2E,0x63,0x72,0x74,0x30,0x82,0x01,
    0x80,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0xD6,0x79,0x02,0x04,0x02,0x04,0x82,0x01,
    0x70,0x04,0x82,0x01,0x6C,0x01,0x6A,0x00,0x76,0x00,0xA4,0xB9,0x09,0x90,0xB4,0x18,
    0x58,0x14,0x87,0xBB,0x13,0xA2,0xCC,0x67,0x70,0x0A,0x3C,0x35,0x98,0x04,0xF9,0x1B,
    0xDF,0xB8,0xE3,0x77,0xCD,0x0E,0xC8,0x0D,0xDC,0x10,0x00,0x00,0x01,0x4C,0xC9,0xBC,
    0xCE,0x1F,0x00,0x00,0x04,0x03,0x00,0x47,0x30,0x45,0x02,0x20,0x46,0xBB,0x30,0x0F,
    0x9D,0x24,0xA2,0xDB,0x55,0x3C,0xB8,0x40,0x82,0x53,0x3B,0x46,0xD3,0x79,0xF8,0x30,
    0x3E,0xC6,0x8D,0x5A,0x2E,0x2D,0x81,0x31,0xAA,0x56,0x52,0x38,0x02,0x21,0x00,0xF3,
    0x83,0xCD,0x9A,0xD5,0xD3,0x94,0x7F,0xB2,0x57,0xDA,0xC9,0xD5,0xAC,0x3C,0x86,0x19,
    0xC2,0x8F,0x7C,0x54,0x51,0xED,0x1A,0xA3,0x6B,0x6C,0x78,0x40,0xD6,0x5C,0xD2,0x00,
    0x77,0x00,0x56,0x14,0x06,0x9A,0x2F,0xD7,0xC2,0xEC,0xD3,0xF5,0xE1,0xBD,0x44,0xB2,
    0x3E,0xC7,0x46,0x76,0xB9,0xBC,0x99,0x11,0x5C,0xC0,0xEF,0x94,0x98,0x55,0xD6,0x89,
    0xD0,0xDD,0x00,0x00,0x01,0x4C,0xC9,0xBC,0xCF,0x0C,0x00,0x00,0x04,0x03,0x00,0x48,
    0x30,0x46,0x02,0x21,0x00,0xCE,0x7C,0x18,0x1B,0xD8,0x76,0x19,0x5E,0xEC,0x96,0x29,
    0x04,0xA8,0x8A,0xCC,0x09,0xDE,0x8D,0x44,0x92,0x73,0xB1,0x6E,0x51,0xC5,0x7C,0xEF,
    0xCD,0x3B,0xD6,0x71,0xED,0x02,0x21,0x00,0xF9,0x7A,0x53,0x68,0x24,0x14,0x3B,0xB3,
    0xFF,0x6B,0x67,0xFB,0x34,0x07,0x85,0xA2,0xD1,0x04,0xE1,0x8E,0x5A,0x6E,0xE6,0xFB,
    0xEA,0x8E,0x04,0x79,0x3E,0x2E,0xF1,0xD7,0x00,0x77,0x00,0x68,0xF6,0x98,0xF8,0x1F,
    0x64,0x82,0xBE,0x3A,0x8C,0xEE,0xB9,0x28,0x1D,0x4C,0xFC,0x71,0x51,0x5D,0x67,0x93,
    0xD4,0x44,0xD1,0x0A,0x67,0xAC,0xBB,0x4F,0x4F,0xFB,0xC4,0x00,0x00,0x01,0x4C,0xC9,
    0xBC,0xCE,0x43,0x00,0x00,0x04,0x03,0x00,0x48,0x30,0x46,0x02,0x21,0x00,0xE4,0x56,
    0x75,0xAE,0x7E,0xD9,0x7C,0x82,0x93,0x4E,0xA4,0x77,0x6C,0x79,0x17,0xE6,0x2D,0x0A,
    0x0C,0xFC,0x68,0x83,0x83,0xDC,0x38,0x7F,0x03,0x6D,0xB9,0xFC,0x17,0x13,0x02,0x21,
    0x00,0xDE,0x03,0x66,0x65,0x43,0xFF,0x1A,0x7C,0x14,0x86,0x78,0xB3,0xA5,0xF0,0xBA,
    0x97,0xA7,0x8A,0xE5,0x44,0xCF,0x65,0x7B,0xDB,0x6A,0x54,0x0D,0x4E,0x8D,0x9C,0x12,
    0xDF,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,
    0x03,0x82,0x01,0x01,0x00,0xC9,0x38,0xED,0x91,0x34,0x2D,0xE5,0x99,0x30,0xCC,0xBE,
    0x64,0x95,0xE1,0xB4,0xBC,0x6D,0x25,0xC3,0x9B,0x09,0xD6,0xE3,0x32,0x1B,0x7B,0xE3,
    0xCE,0x57,0xB2,0xB4,0x42,0x74,0xAD,0x59,0x89,0x44,0x7B,0x73,0xF1,0x45,0x75,0x1C,
    0x12,0x34,0xC4,0x10,0x6C,0x16,0x28,0x00,0xD2,0xFE,0xFD,0xB6,0x5F,0xB3,0xDF,0x11,
    0x0E,0xBE,0x62,0xC8,0xA2,0x5D,0xC2,0x23,0xFD,0xCD,0x4E,0x49,0xCB,0xBA,0xC5,0x6A,
    0xFB,0xA3,0x47,0x5A,0x3C,0x2B,0xCD,0xB7,0x39,0xED,0xB7,0x05,0x00,0x46,0x86,0xE3,
    0x7A,0x71,0x58,0x85,0x4C,0xD9,0x17,0x5D,0xFD,0xDC,0xB2,0x22,0xE1,0x05,0x13,0x22,
    0x74,0x11,0x4E,0x8A,0x27,0x13,0x46,0x7E,0xF4,0xA5,0x6E,0x4E,0x9A,0xEF,0x73,0x1F,
    0x44,0x4C,0x3C,0xD7,0x48,0xC8,0x5C,0xEF,0x39,0xEA,0x8C,0x09,0xBA,0x19,0x14,0x45,
    0x0F,0x61,0x43,0x9E,0x7F,0xEA,0xD9,0xD8,0xD8,0xE3,0x96,0xA3,0x82,0x31,0x2D,0x1C,
    0x25,0x4E,0xC3,0x9E,0xDD,0xAB,0xEF,0x2A,0xC2,0x7E,0x35,0x24,0x8F,0x75,0xED,0x03,
    0x83,0x61,0x24,0xF8,0xC1,0x4F,0x48,0xD5,0x54,0xB5,0xA4,0x4A,0x1C,0x9B,0x8F,0x25,
    0x51,0x9A,0xC2,0xE8,0x98,0x84,0x83,0x45,0x71,0xB0,0x5E,0x6B,0x91,0x61,0xA9,0xDA,
    0xF5,0x0E,0xB9,0xA8,0x2D,0x2D,0x94,0x42,0xA5,0xF4,0xBE,0x7B,0xD3,0x19,0x8E,0xCD,
    0x4A,0xB6,0x47,0x9E,0x54,0x5D,0xD7,0x3C,0x69,0x01,0x44,0x15,0x09,0xDA,0xA8,0x89,
    0x87,0x1A,0x73,0x7A,0x13,0xC7,0x0F,0xA9,0xB7,0x75,0x3D,0x3A,0x27,0x4C,0x49,0x08,
    0xC7,0xE7,0xE9,0x6F,0xD9,
};

/* subject:/C=US/O=Symantec Corporation/OU=Symantec Trust Network/CN=Symantec Class 3 EV SSL CA - G3 */
/* issuer :/C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=(c) 2006 VeriSign, Inc. - For authorized use only/CN=VeriSign Class 3 Public Primary Certification Authority - G5 */

static unsigned char _c1[]={
    0x30,0x82,0x05,0x2B,0x30,0x82,0x04,0x13,0xA0,0x03,0x02,0x01,0x02,0x02,0x10,0x7E,
    0xE1,0x4A,0x6F,0x6F,0xEF,0xF2,0xD3,0x7F,0x3F,0xAD,0x65,0x4D,0x3A,0xDA,0xB4,0x30,
    0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x30,0x81,
    0xCA,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x17,
    0x30,0x15,0x06,0x03,0x55,0x04,0x0A,0x13,0x0E,0x56,0x65,0x72,0x69,0x53,0x69,0x67,
    0x6E,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1F,0x30,0x1D,0x06,0x03,0x55,0x04,0x0B,
    0x13,0x16,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x20,0x54,0x72,0x75,0x73,0x74,
    0x20,0x4E,0x65,0x74,0x77,0x6F,0x72,0x6B,0x31,0x3A,0x30,0x38,0x06,0x03,0x55,0x04,
    0x0B,0x13,0x31,0x28,0x63,0x29,0x20,0x32,0x30,0x30,0x36,0x20,0x56,0x65,0x72,0x69,
    0x53,0x69,0x67,0x6E,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x20,0x2D,0x20,0x46,0x6F,0x72,
    0x20,0x61,0x75,0x74,0x68,0x6F,0x72,0x69,0x7A,0x65,0x64,0x20,0x75,0x73,0x65,0x20,
    0x6F,0x6E,0x6C,0x79,0x31,0x45,0x30,0x43,0x06,0x03,0x55,0x04,0x03,0x13,0x3C,0x56,
    0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x20,0x43,0x6C,0x61,0x73,0x73,0x20,0x33,0x20,
    0x50,0x75,0x62,0x6C,0x69,0x63,0x20,0x50,0x72,0x69,0x6D,0x61,0x72,0x79,0x20,0x43,
    0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,
    0x68,0x6F,0x72,0x69,0x74,0x79,0x20,0x2D,0x20,0x47,0x35,0x30,0x1E,0x17,0x0D,0x31,
    0x33,0x31,0x30,0x33,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5A,0x17,0x0D,0x32,0x33,
    0x31,0x30,0x33,0x30,0x32,0x33,0x35,0x39,0x35,0x39,0x5A,0x30,0x77,0x31,0x0B,0x30,
    0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x1D,0x30,0x1B,0x06,0x03,
    0x55,0x04,0x0A,0x13,0x14,0x53,0x79,0x6D,0x61,0x6E,0x74,0x65,0x63,0x20,0x43,0x6F,
    0x72,0x70,0x6F,0x72,0x61,0x74,0x69,0x6F,0x6E,0x31,0x1F,0x30,0x1D,0x06,0x03,0x55,
    0x04,0x0B,0x13,0x16,0x53,0x79,0x6D,0x61,0x6E,0x74,0x65,0x63,0x20,0x54,0x72,0x75,
    0x73,0x74,0x20,0x4E,0x65,0x74,0x77,0x6F,0x72,0x6B,0x31,0x28,0x30,0x26,0x06,0x03,
    0x55,0x04,0x03,0x13,0x1F,0x53,0x79,0x6D,0x61,0x6E,0x74,0x65,0x63,0x20,0x43,0x6C,
    0x61,0x73,0x73,0x20,0x33,0x20,0x45,0x56,0x20,0x53,0x53,0x4C,0x20,0x43,0x41,0x20,
    0x2D,0x20,0x47,0x33,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,
    0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A,
    0x02,0x82,0x01,0x01,0x00,0xD8,0xA1,0x65,0x74,0x23,0xE8,0x2B,0x64,0xE2,0x32,0xD7,
    0x33,0x37,0x3D,0x8E,0xF5,0x34,0x16,0x48,0xDD,0x4F,0x7F,0x87,0x1C,0xF8,0x44,0x23,
    0x13,0x8E,0xFB,0x11,0xD8,0x44,0x5A,0x18,0x71,0x8E,0x60,0x16,0x26,0x92,0x9B,0xFD,
    0x17,0x0B,0xE1,0x71,0x70,0x42,0xFE,0xBF,0xFA,0x1C,0xC0,0xAA,0xA3,0xA7,0xB5,0x71,
    0xE8,0xFF,0x18,0x83,0xF6,0xDF,0x10,0x0A,0x13,0x62,0xC8,0x3D,0x9C,0xA7,0xDE,0x2E,
    0x3F,0x0C,0xD9,0x1D,0xE7,0x2E,0xFB,0x2A,0xCE,0xC8,0x9A,0x7F,0x87,0xBF,0xD8,0x4C,
    0x04,0x15,0x32,0xC9,0xD1,0xCC,0x95,0x71,0xA0,0x4E,0x28,0x4F,0x84,0xD9,0x35,0xFB,
    0xE3,0x86,0x6F,0x94,0x53,0xE6,0x72,0x8A,0x63,0x67,0x2E,0xBE,0x69,0xF6,0xF7,0x6E,
    0x8E,0x9C,0x60,0x04,0xEB,0x29,0xFA,0xC4,0x47,0x42,0xD2,0x78,0x98,0xE3,0xEC,0x0B,
    0xA5,0x92,0xDC,0xB7,0x9A,0xBD,0x80,0x64,0x2B,0x38,0x7C,0x38,0x09,0x5B,0x66,0xF6,
    0x2D,0x95,0x7A,0x86,0xB2,0x34,0x2E,0x85,0x9E,0x90,0x0E,0x5F,0xB7,0x5D,0xA4,0x51,
    0x72,0x46,0x70,0x13,0xBF,0x67,0xF2,0xB6,0xA7,0x4D,0x14,0x1E,0x6C,0xB9,0x53,0xEE,
    0x23,0x1A,0x4E,0x8D,0x48,0x55,0x43,0x41,0xB1,0x89,0x75,0x6A,0x40,0x28,0xC5,0x7D,
    0xDD,0xD2,0x6E,0xD2,0x02,0x19,0x2F,0x7B,0x24,0x94,0x4B,0xEB,0xF1,0x1A,0xA9,0x9B,
    0xE3,0x23,0x9A,0xEA,0xFA,0x33,0xAB,0x0A,0x2C,0xB7,0xF4,0x60,0x08,0xDD,0x9F,0x1C,
    0xCD,0xDD,0x2D,0x01,0x66,0x80,0xAF,0xB3,0x2F,0x29,0x1D,0x23,0xB8,0x8A,0xE1,0xA1,
    0x70,0x07,0x0C,0x34,0x0F,0x02,0x03,0x01,0x00,0x01,0xA3,0x82,0x01,0x5D,0x30,0x82,
    0x01,0x59,0x30,0x2F,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x01,0x04,0x23,
    0x30,0x21,0x30,0x1F,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x86,0x13,
    0x68,0x74,0x74,0x70,0x3A,0x2F,0x2F,0x73,0x32,0x2E,0x73,0x79,0x6D,0x63,0x62,0x2E,
    0x63,0x6F,0x6D,0x30,0x12,0x06,0x03,0x55,0x1D,0x13,0x01,0x01,0xFF,0x04,0x08,0x30,
    0x06,0x01,0x01,0xFF,0x02,0x01,0x00,0x30,0x65,0x06,0x03,0x55,0x1D,0x20,0x04,0x5E,
    0x30,0x5C,0x30,0x5A,0x06,0x04,0x55,0x1D,0x20,0x00,0x30,0x52,0x30,0x26,0x06,0x08,
    0x2B,0x06,0x01,0x05,0x05,0x07,0x02,0x01,0x16,0x1A,0x68,0x74,0x74,0x70,0x3A,0x2F,
    0x2F,0x77,0x77,0x77,0x2E,0x73,0x79,0x6D,0x61,0x75,0x74,0x68,0x2E,0x63,0x6F,0x6D,
    0x2F,0x63,0x70,0x73,0x30,0x28,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x02,0x02,
    0x30,0x1C,0x1A,0x1A,0x68,0x74,0x74,0x70,0x3A,0x2F,0x2F,0x77,0x77,0x77,0x2E,0x73,
    0x79,0x6D,0x61,0x75,0x74,0x68,0x2E,0x63,0x6F,0x6D,0x2F,0x72,0x70,0x61,0x30,0x30,
    0x06,0x03,0x55,0x1D,0x1F,0x04,0x29,0x30,0x27,0x30,0x25,0xA0,0x23,0xA0,0x21,0x86,
    0x1F,0x68,0x74,0x74,0x70,0x3A,0x2F,0x2F,0x73,0x31,0x2E,0x73,0x79,0x6D,0x63,0x62,
    0x2E,0x63,0x6F,0x6D,0x2F,0x70,0x63,0x61,0x33,0x2D,0x67,0x35,0x2E,0x63,0x72,0x6C,
    0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x01,0x06,
    0x30,0x29,0x06,0x03,0x55,0x1D,0x11,0x04,0x22,0x30,0x20,0xA4,0x1E,0x30,0x1C,0x31,
    0x1A,0x30,0x18,0x06,0x03,0x55,0x04,0x03,0x13,0x11,0x53,0x79,0x6D,0x61,0x6E,0x74,
    0x65,0x63,0x50,0x4B,0x49,0x2D,0x31,0x2D,0x35,0x33,0x33,0x30,0x1D,0x06,0x03,0x55,
    0x1D,0x0E,0x04,0x16,0x04,0x14,0x01,0x59,0xAB,0xE7,0xDD,0x3A,0x0B,0x59,0xA6,0x64,
    0x63,0xD6,0xCF,0x20,0x07,0x57,0xD5,0x91,0xE7,0x6A,0x30,0x1F,0x06,0x03,0x55,0x1D,
    0x23,0x04,0x18,0x30,0x16,0x80,0x14,0x7F,0xD3,0x65,0xA7,0xC2,0xDD,0xEC,0xBB,0xF0,
    0x30,0x09,0xF3,0x43,0x39,0xFA,0x02,0xAF,0x33,0x31,0x33,0x30,0x0D,0x06,0x09,0x2A,
    0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x42,
    0x01,0x55,0x7B,0xD0,0x16,0x1A,0x5D,0x58,0xE8,0xBB,0x9B,0xA8,0x4D,0xD7,0xF3,0xD7,
    0xEB,0x13,0x94,0x86,0xD6,0x7F,0x21,0x0B,0x47,0xBC,0x57,0x9B,0x92,0x5D,0x4F,0x05,
    0x9F,0x38,0xA4,0x10,0x7C,0xCF,0x83,0xBE,0x06,0x43,0x46,0x8D,0x08,0xBC,0x6A,0xD7,
    0x10,0xA6,0xFA,0xAB,0xAF,0x2F,0x61,0xA8,0x63,0xF2,0x65,0xDF,0x7F,0x4C,0x88,0x12,
    0x88,0x4F,0xB3,0x69,0xD9,0xFF,0x27,0xC0,0x0A,0x97,0x91,0x8F,0x56,0xFB,0x89,0xC4,
    0xA8,0xBB,0x92,0x2D,0x1B,0x73,0xB0,0xC6,0xAB,0x36,0xF4,0x96,0x6C,0x20,0x08,0xEF,
    0x0A,0x1E,0x66,0x24,0x45,0x4F,0x67,0x00,0x40,0xC8,0x07,0x54,0x74,0x33,0x3B,0xA6,
    0xAD,0xBB,0x23,0x9F,0x66,0xED,0xA2,0x44,0x70,0x34,0xFB,0x0E,0xEA,0x01,0xFD,0xCF,
    0x78,0x74,0xDF,0xA7,0xAD,0x55,0xB7,0x5F,0x4D,0xF6,0xD6,0x3F,0xE0,0x86,0xCE,0x24,
    0xC7,0x42,0xA9,0x13,0x14,0x44,0x35,0x4B,0xB6,0xDF,0xC9,0x60,0xAC,0x0C,0x7F,0xD9,
    0x93,0x21,0x4B,0xEE,0x9C,0xE4,0x49,0x02,0x98,0xD3,0x60,0x7B,0x5C,0xBC,0xD5,0x30,
    0x2F,0x07,0xCE,0x44,0x42,0xC4,0x0B,0x99,0xFE,0xE6,0x9F,0xFC,0xB0,0x78,0x86,0x51,
    0x6D,0xD1,0x2C,0x9D,0xC6,0x96,0xFB,0x85,0x82,0xBB,0x04,0x2F,0xF7,0x62,0x80,0xEF,
    0x62,0xDA,0x7F,0xF6,0x0E,0xAC,0x90,0xB8,0x56,0xBD,0x79,0x3F,0xF2,0x80,0x6E,0xA3,
    0xD9,0xB9,0x0F,0x5D,0x3A,0x07,0x1D,0x91,0x93,0x86,0x4B,0x29,0x4C,0xE1,0xDC,0xB5,
    0xE1,0xE0,0x33,0x9D,0xB3,0xCB,0x36,0x91,0x4B,0xFE,0xA1,0xB4,0xEE,0xF0,0xF9,
};

/* subject:/CN=self-signed.ssltest.apple.com/C=US */
/* issuer :/CN=self-signed.ssltest.apple.com/C=US */

static unsigned char _ss0[]={
	0x30,0x82,0x03,0x0F,0x30,0x82,0x01,0xF7,0xA0,0x03,0x02,0x01,0x02,0x02,0x01,0x01,
	0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x30,
	0x35,0x31,0x26,0x30,0x24,0x06,0x03,0x55,0x04,0x03,0x0C,0x1D,0x73,0x65,0x6C,0x66,
	0x2D,0x73,0x69,0x67,0x6E,0x65,0x64,0x2E,0x73,0x73,0x6C,0x74,0x65,0x73,0x74,0x2E,
	0x61,0x70,0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,
	0x04,0x06,0x13,0x02,0x55,0x53,0x30,0x1E,0x17,0x0D,0x31,0x36,0x30,0x36,0x30,0x37,
	0x32,0x31,0x35,0x33,0x30,0x38,0x5A,0x17,0x0D,0x31,0x37,0x30,0x36,0x30,0x37,0x32,
	0x31,0x35,0x33,0x30,0x38,0x5A,0x30,0x35,0x31,0x26,0x30,0x24,0x06,0x03,0x55,0x04,
	0x03,0x0C,0x1D,0x73,0x65,0x6C,0x66,0x2D,0x73,0x69,0x67,0x6E,0x65,0x64,0x2E,0x73,
	0x73,0x6C,0x74,0x65,0x73,0x74,0x2E,0x61,0x70,0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,
	0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x30,0x82,0x01,
	0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,
	0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xCC,0x72,
	0x7D,0x09,0x36,0x5A,0x6A,0xED,0xC1,0x7A,0x2C,0xF4,0x7C,0x58,0x63,0x05,0x3E,0x91,
	0x68,0x55,0xB1,0x2A,0x5D,0x57,0xF3,0xA4,0xA7,0x80,0x05,0x41,0x74,0xB2,0xAD,0x5A,
	0x7F,0x38,0xF6,0xF7,0xFD,0xF9,0x64,0x4D,0xDE,0xF9,0x7A,0xD3,0x8C,0x78,0xE9,0x71,
	0xCF,0x1D,0x3E,0xF0,0xDB,0x12,0x48,0x74,0x22,0xA8,0x1F,0x3F,0xB9,0xDD,0xB0,0xAD,
	0x8C,0x10,0x64,0x05,0x0E,0xE2,0x59,0x9A,0xEB,0x3F,0xBF,0xA9,0x48,0x07,0xD9,0x2C,
	0x07,0x44,0x70,0x14,0x16,0x56,0x9C,0x73,0x01,0x2E,0x0B,0xF1,0x2A,0x9F,0x1C,0xC6,
	0x78,0x56,0xB7,0x0B,0xDA,0xA6,0xE6,0x99,0x87,0x2D,0x49,0xFB,0xF0,0x47,0x22,0xA6,
	0x8B,0xF0,0x02,0x37,0x31,0xD0,0x34,0x9F,0x43,0xD1,0x24,0x49,0x94,0x7F,0xFD,0x48,
	0x9C,0xBA,0x5D,0x6B,0xD4,0xF9,0x9E,0xB5,0x18,0xE4,0xB2,0x06,0x46,0xC3,0xD9,0xE7,
	0x80,0xD8,0x61,0xA9,0x09,0x5E,0xBA,0x2E,0x58,0x56,0xAE,0x37,0x31,0x6E,0x87,0x98,
	0xD5,0xC9,0x2B,0x31,0x5C,0x40,0x01,0xDF,0xD5,0x63,0x9E,0x05,0x18,0x21,0x53,0x70,
	0x62,0x36,0x44,0xCD,0x02,0xC0,0xCC,0x6A,0x58,0xC6,0xF6,0xA4,0xDC,0x89,0x94,0xBD,
	0x4E,0xC4,0xEE,0xEE,0x40,0x31,0x59,0xC3,0x43,0xAD,0x34,0x30,0xDE,0xA9,0xA7,0x0D,
	0x85,0xF7,0x96,0x8C,0x45,0xC1,0x6E,0x85,0x39,0x97,0xA6,0x4F,0xEA,0xE8,0x2F,0x01,
	0x3D,0xC0,0x3B,0x34,0x9F,0x8F,0xCB,0xD6,0x22,0x79,0x2C,0x8C,0x8C,0xE6,0xBB,0x1F,
	0x89,0x87,0x93,0x3B,0x39,0x4E,0x64,0x7D,0xDA,0x4D,0x52,0x4C,0x97,0xE5,0x02,0x03,
	0x01,0x00,0x01,0xA3,0x2A,0x30,0x28,0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,
	0xFF,0x04,0x04,0x03,0x02,0x07,0x80,0x30,0x16,0x06,0x03,0x55,0x1D,0x25,0x01,0x01,
	0xFF,0x04,0x0C,0x30,0x0A,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x01,0x30,
	0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,0x82,
	0x01,0x01,0x00,0x36,0x06,0xC9,0xE6,0x98,0xC2,0x84,0x1D,0x13,0x1E,0x54,0x35,0x6D,
	0xE5,0xCB,0xC5,0xFD,0xD9,0x54,0x45,0x83,0x53,0xB3,0x3B,0xE7,0x30,0x6F,0xAE,0xEA,
	0x63,0x3F,0xA8,0xFA,0xD9,0x6D,0x0F,0x7D,0xD4,0xB6,0x28,0x66,0xF9,0x57,0x87,0x3E,
	0x57,0x27,0xB6,0x9A,0x56,0xAE,0xD7,0xE0,0x11,0x20,0x71,0xC1,0xEA,0xF6,0xED,0x74,
	0x1A,0x5A,0xB1,0x74,0x6C,0xBE,0xAC,0x0E,0x3C,0xD9,0x3E,0xEC,0x17,0x6E,0xF0,0x69,
	0xC9,0x4D,0xD2,0x7E,0xAE,0x8B,0x01,0xCC,0x1A,0x23,0x7C,0x58,0x07,0x30,0xE4,0x2A,
	0x12,0xE8,0xA0,0x25,0x65,0x66,0xB5,0xC7,0x5D,0xD8,0x47,0xDF,0xD7,0x51,0xBC,0xA2,
	0xAA,0xF0,0x2F,0xB5,0x9E,0x20,0x6D,0x1F,0x84,0x00,0xF0,0xD0,0xB8,0x42,0x6A,0x9A,
	0xE7,0xCA,0x7B,0xE5,0x39,0x09,0x91,0xBF,0xCB,0x4D,0x7A,0x32,0x1E,0x00,0x6E,0xE5,
	0xF7,0x44,0x80,0x82,0x38,0x53,0x64,0xB7,0x26,0x81,0xCB,0xCE,0xA1,0xAF,0x0C,0x67,
	0x32,0xC6,0xE4,0x5D,0x09,0x7B,0x37,0xD7,0xC8,0x43,0x44,0xEF,0xC6,0xF8,0x72,0xFF,
	0x65,0xD4,0x39,0x3D,0xEC,0x72,0xA5,0x28,0xFF,0x70,0x47,0x38,0xA3,0xC7,0xCC,0x5E,
	0x0F,0xFF,0x43,0x83,0x78,0x49,0x68,0x90,0x48,0x89,0xAD,0xE1,0x2E,0xFA,0x8F,0x59,
	0xB6,0x08,0x2A,0x72,0x2F,0x52,0x3F,0x73,0x84,0xCA,0xD8,0x18,0x6C,0xDA,0xA3,0x2E,
	0xF2,0xD7,0x4C,0x21,0xD9,0xF8,0xB1,0x86,0xE9,0x35,0x78,0xE4,0x4F,0xD0,0x93,0x11,
	0x8F,0xF4,0xB1,0x17,0x4F,0xDE,0xAC,0xBD,0xA9,0xBC,0x94,0xFC,0x2E,0x7D,0xF9,0x05,
	0x26,0x90,0xF1,
};

#define CFReleaseSafe(CF) { CFTypeRef _cf = (CF); if (_cf) CFRelease(_cf); }
#define CFReleaseNull(CF) { CFTypeRef _cf = (CF); if (_cf) { (CF) = NULL; CFRelease(_cf); } }

/* Test basic add delete update copy matching stuff. */
static void tests(void)
{
	SecTrustRef trust;
	SecCertificateRef cert0, cert1, sscert0;
	CFArrayRef anchors = NULL;
	isnt(cert0 = SecCertificateCreateWithBytes(NULL, _c0, sizeof(_c0)),
			NULL, "create cert0");
	isnt(cert1 = SecCertificateCreateWithBytes(NULL, _c1, sizeof(_c1)),
			NULL, "create cert1");
	isnt(sscert0 = SecCertificateCreateWithBytes(NULL, _ss0, sizeof(_ss0)),
			NULL, "create sscert0");
	const void *v_certs[] = {
		cert0,
		cert1
	};
	SecPolicyRef policy = SecPolicyCreateSSL(false, CFSTR("secure.store.apple.com"));
	CFArrayRef certs = CFArrayCreate(NULL, v_certs,
			array_size(v_certs), NULL);
	ok_status(SecTrustCreateWithCertificates(certs, policy, &trust), "create trust");
	/* Jun 12 2015. */
	CFDateRef date = CFDateCreate(NULL, 455843208.0);
	ok_status(SecTrustSetVerifyDate(trust, date), "set date");

	SecTrustResultType trustResult;
	ok_status(SecTrustEvaluate(trust, &trustResult), "evaluate trust");
	is_status(trustResult, kSecTrustResultUnspecified,
			"trust is kSecTrustResultUnspecified");
	CFDataRef exceptions;
	ok(exceptions = SecTrustCopyExceptions(trust), "create exceptions");
	if (!exceptions) { goto errOut; }
	ok(SecTrustSetExceptions(trust, exceptions), "set exceptions");
	ok_status(SecTrustEvaluate(trust, &trustResult), "evaluate trust");
	is_status(trustResult, kSecTrustResultProceed, "trust is kSecTrustResultProceed");

	CFReleaseNull(trust);
	CFReleaseNull(policy);
	policy = SecPolicyCreateSSL(false, CFSTR("badstore.apple.com"));
	ok_status(SecTrustCreateWithCertificates(certs, policy, &trust), "create trust with hostname mismatch");
	ok_status(SecTrustSetVerifyDate(trust, date), "set date");
	ok(SecTrustSetExceptions(trust, exceptions), "set old exceptions");
	ok_status(SecTrustEvaluate(trust, &trustResult), "evaluate trust");
	is_status(trustResult, kSecTrustResultRecoverableTrustFailure, "trust is kSecTrustResultRecoverableTrustFailure");
	CFReleaseNull(exceptions);
	ok(exceptions = SecTrustCopyExceptions(trust), "create exceptions");
	if (!exceptions) { goto errOut; }
	ok(SecTrustSetExceptions(trust, exceptions), "set exceptions");
	ok_status(SecTrustEvaluate(trust, &trustResult), "evaluate trust");
	is_status(trustResult, kSecTrustResultProceed, "trust is kSecTrustResultProceed");

	CFReleaseNull(trust);
	ok_status(SecTrustCreateWithCertificates(certs, policy, &trust), "create trust");
	ok_status(SecTrustSetVerifyDate(trust, date), "set date");
	ok(SecTrustSetExceptions(trust, exceptions), "set exceptions");
	ok_status(SecTrustEvaluate(trust, &trustResult), "evaluate trust");
	is_status(trustResult, kSecTrustResultProceed, "trust is kSecTrustResultProceed");
	anchors = CFArrayCreate(kCFAllocatorDefault, NULL, 0, &kCFTypeArrayCallBacks);
	ok_status(SecTrustSetAnchorCertificates(trust, anchors), "set empty anchor list");
	ok_status(SecTrustEvaluate(trust, &trustResult), "evaluate trust");
	is_status(trustResult, kSecTrustResultRecoverableTrustFailure, "trust is kSecTrustResultRecoverableTrustFailure");

	ok_status(SecTrustSetAnchorCertificatesOnly(trust, false), "trust passed in anchors and system anchors");
	ok_status(SecTrustEvaluate(trust, &trustResult), "evaluate trust");
	is_status(trustResult, kSecTrustResultProceed, "trust is now kSecTrustResultProceed");

	ok_status(SecTrustSetAnchorCertificatesOnly(trust, true), "only trust passed in anchors (default)");
	ok_status(SecTrustEvaluate(trust, &trustResult), "evaluate trust");
	is_status(trustResult, kSecTrustResultRecoverableTrustFailure, "trust is kSecTrustResultRecoverableTrustFailure again");

	CFReleaseNull(exceptions);
	ok(exceptions = SecTrustCopyExceptions(trust), "create exceptions");
	if (!exceptions) { goto errOut; }
	ok(SecTrustSetExceptions(trust, exceptions), "set exceptions");
	ok_status(SecTrustEvaluate(trust, &trustResult), "evaluate trust");
	is_status(trustResult, kSecTrustResultProceed, "trust is kSecTrustResultProceed");
	CFReleaseNull(date);
	date = CFDateCreate(NULL, 667680000.0);
	ok_status(SecTrustSetVerifyDate(trust, date), "set date to far future so certs are expired");
	ok_status(SecTrustEvaluate(trust, &trustResult), "evaluate trust");
	is_status(trustResult, kSecTrustResultRecoverableTrustFailure, "trust is kSecTrustResultRecoverableTrustFailure");

	CFReleaseNull(trust);
	CFReleaseNull(policy);
	policy = SecPolicyCreateSSL(false, CFSTR("self-signed.ssltest.apple.com"));
	ok_status(SecTrustCreateWithCertificates(sscert0, policy, &trust), "create trust");
	ok_status(SecTrustEvaluate(trust, &trustResult), "evaluate trust");
	is_status(trustResult, kSecTrustResultRecoverableTrustFailure, "trust is kSecTrustResultRecoverableTrustFailure");
	CFReleaseNull(exceptions);
	ok(exceptions = SecTrustCopyExceptions(trust), "create exceptions");
	if (!exceptions) { goto errOut; }
	ok(SecTrustSetExceptions(trust, exceptions), "set exceptions");
	ok_status(SecTrustEvaluate(trust, &trustResult), "evaluate trust");
	is_status(trustResult, kSecTrustResultProceed, "trust is kSecTrustResultProceed");
    CFReleaseNull(exceptions);
	ok(!SecTrustSetExceptions(trust, NULL), "clear exceptions");
	ok_status(SecTrustEvaluate(trust, &trustResult), "evaluate trust");
	is_status(trustResult, kSecTrustResultRecoverableTrustFailure, "trust is kSecTrustResultRecoverableTrustFailure");

errOut:
	CFReleaseSafe(anchors);
	CFReleaseSafe(exceptions);
	CFReleaseSafe(trust);
	CFReleaseSafe(policy);
	CFReleaseSafe(certs);
	CFReleaseSafe(cert0);
	CFReleaseSafe(cert1);
	CFReleaseSafe(sscert0);
	CFReleaseSafe(date);
}

int si_27_sectrust_exceptions(int argc, char *const *argv)
{
	plan_tests(51);


	tests();

	return 0;
}
